const screenWidth = window.innerWidth
const screenHeight = window.innerHeight

import global from './global'


/**
 * 敌机
 */
export default class Sprite {

  constructor(imgSrc, width, height, x = 0 , y = 0) {
    this.img = new Image()
    this.img.src = imgSrc
    this.x = x
    this.y = y
    this.width = width
    this.height = height
    this.visible = true
  }

  isCollideWith(sp) {
    if (!this.visible || !sp.visible) {
      return false
    }
    let spX = sp.x + sp.width / 2
    let spY = sp.y + sp.height / 2
    let onX = spX >= this.x && spX <= this.x + this.width
    let onY = spY >= this.y && spY <= this.y + this.height
    return onX && onY
  }
}
